/*     */ package nccloud.web.qc.pub.reportandrejectbill;
/*     */ 
/*     */ import java.util.HashSet;
/*     */ import java.util.Set;
/*     */ import nc.pubitf.qc.c002.qc.c003.IQueryForC003;
/*     */ import nc.vo.ml.NCLangRes4VoTransl;
/*     */ import nc.vo.pub.BusinessException;
/*     */ import nc.vo.pubapp.pattern.data.ValueUtils;
/*     */ import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
/*     */ import nc.vo.qc.c002.entity.CheckBillViewVO;
/*     */ import nc.vo.qc.c002.util.FakeCheckBillUtil;
/*     */ import nccloud.framework.core.exception.ExceptionUtils;
/*     */ import nccloud.framework.core.json.IJson;
/*     */ import nccloud.framework.core.util.ArrayUtils;
/*     */ import nccloud.framework.service.ServiceLocator;
/*     */ import nccloud.framework.web.action.itf.ICommonAction;
/*     */ import nccloud.framework.web.container.IRequest;
/*     */ import nccloud.framework.web.json.JsonFactory;
/*     */ import nccloud.framework.web.ui.pattern.billcard.BillCard;
/*     */ import nccloud.framework.web.ui.pattern.billcard.BillCardOperator;
/*     */ import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCard;
/*     */ import nccloud.framework.web.ui.pattern.grid.Grid;
/*     */ import nccloud.framework.web.ui.pattern.grid.GridOperator;
/*     */ import nccloud.web.qc.pub.entity.CheckInfoMultiTabDTO;
/*     */ import nccloud.web.qc.pub.entity.MultiTabQueryInfo;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class AbstractQueryByPKAction
/*     */   implements ICommonAction
/*     */ {
/*     */   public Object doAction(IRequest request) {
/*  38 */     String str = request.read();
/*  39 */     IJson json = JsonFactory.create();
/*  40 */     MultiTabQueryInfo info = (MultiTabQueryInfo)json.fromJson(str, MultiTabQueryInfo.class);
/*  41 */     AbstractBill[] bills = null;
/*     */     try {
/*  43 */       bills = queryBill(new String[] { info.getPk() });
/*     */     }
/*  45 */     catch (Exception e) {
/*  46 */       ExceptionUtils.wrapException(e);
/*     */     } 
/*  48 */     if (ArrayUtils.isEmpty(bills)) {
/*  49 */       ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("c010009_0", "0c010009-0015"));
/*  50 */       return null;
/*     */     } 
/*  52 */     CheckBillViewVO[] checkviews = null;
/*  53 */     String hid = getPk_applybill(bills[0]);
/*  54 */     String chkbat = getPk_chkbatch(bills[0]);
/*  55 */    // checkviews = queryCheckBillViewVO(hid, chkbat);
/*  56 */     Grid checkInfoGrid = null;
/*  57 */     if (ArrayUtils.isNotEmpty(checkviews)) {
/*  58 */       GridOperator gridOperator = new GridOperator(info.getPageid());
/*  59 */       gridOperator.setBodycode(info.getBodyCode());
/*  60 */       checkInfoGrid = gridOperator.toGrid(checkviews);
/*     */     } 
/*     */     
/*  63 */     if (checkInfoGrid != null) {
/*  64 */       processPrecision(checkInfoGrid);
/*     */     }
/*     */     
/*  67 */     BillCardOperator operator = new BillCardOperator(info.getPageid());
/*  68 */     BillCard billcard = operator.toCard(bills[0]);
/*     */     
/*  70 */     processPrecision(billcard);
/*  71 */     ExtBillCard retcard = bulidExtBillCard(checkInfoGrid, billcard);
/*     */     
/*  73 */     CheckInfoTabClientAdapter adapter = new CheckInfoTabClientAdapter(checkviews, info.getCheckInfoAreaCode(), info.getSampleInfoAreaCode());
/*     */     
/*  75 */     CheckInfoMultiTabDTO dto = adapter.buildDTOwithTabs();
/*  76 */     dto.setBill(retcard);
/*     */     
/*  78 */     return dto;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected abstract String getPk_chkbatch(AbstractBill paramAbstractBill);
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected abstract String getPk_applybill(AbstractBill paramAbstractBill);
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected abstract AbstractBill[] queryBill(String[] paramArrayOfString) throws BusinessException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected void processPrecision(BillCard retcard) {}
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected void processPrecision(Grid grid) {}
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   private CheckBillViewVO[] queryCheckBillViewVO(String hid, String pk_chkbatch) {
/* 116 */     CheckBillViewVO[] retviews = null;
/*     */     try {
/* 118 */       IQueryForC003 sr = (IQueryForC003)ServiceLocator.find(IQueryForC003.class);
/* 119 */       retviews = sr.queryChkBillByApplyIDAndBatch(hid, pk_chkbatch);
/* 120 */     } catch (BusinessException ex) {
/* 121 */       ExceptionUtils.wrapException(ex);
/*     */     } 
/*     */     
/* 124 */     retviews = (retviews == null) ? new CheckBillViewVO[0] : retviews;
/* 125 */     Set<String> bdealedHids = new HashSet<String>();
/* 126 */     for (CheckBillViewVO view : retviews) {
/* 127 */       if (ValueUtils.getBoolean(view.getHVO().getBrecheck()))
/*     */       {
/*     */         
/* 130 */         if (!bdealedHids.contains(view.getHVO().getPk_checkbill())) {
/*     */ 
/*     */           
/* 133 */           String voldsample = FakeCheckBillUtil.getSampleCode(view);
/*     */           
/* 135 */           String flag = NCLangRes4VoTransl.getNCLangRes().getStrByID("c010009_0", "0c010009-0016");
/* 136 */           view.getHVO().setVsamplecode(voldsample + flag);
/* 137 */           view.getBVO().setVbsamplecode(voldsample + flag);
/* 138 */           bdealedHids.add(view.getHVO().getPk_checkbill());
/*     */         }  } 
/* 140 */     }  return retviews;
/*     */   }
/*     */   
/*     */   private ExtBillCard bulidExtBillCard(Grid grid, BillCard billCard) {
/* 144 */     ExtBillCard retcard = new ExtBillCard();
/* 145 */     retcard.setHead(billCard.getHead());
/* 146 */     retcard.setPageid(billCard.getPageid());
/* 147 */     retcard.addBody(billCard.getBody());
/* 148 */     if (null != grid) {
/* 149 */       retcard.addBody(grid);
/*     */     }
/* 151 */     return retcard;
/*     */   }
/*     */ }


/* Location:              E:\zhuhai_ncc\NCC2111\external\li\\uiqc_nccloud.jar!/nccloud/web/qc/pub/reportandrejectbill/AbstractQueryByPKAction.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */